export default {
  methods: {
    handleHeightChange(currentValue) {
      this.manager.states.visibleCells.forEach(a => {
        this.currentGridView.Rows[a.RowIndex].Height = currentValue;
      });
    },
    handleWidthChange(currentValue) {
      this.manager.states.visibleCells.forEach(a => {
        this.currentGridView.Columns[a.ColumnIndex].Width = currentValue;
      });
    },
    handleLeftBorder() {
      const first = this.manager.states.visibleCells[0];
      let flag = false;
      if (first.BorderLeftLineStyle === 'None') {
        flag = true;
      }
      this.manager.states.visibleCells.forEach(a => {
        a.BorderLeftLineStyle = flag ? 'Solid' : 'None';
      });
    },
    handleLeftBorderCommand(command) {
      this.manager.states.visibleCells.forEach(a => {
        if (isNaN(command)) {
          a.BorderLeftLineStyle = command;
        } else {
          a.BorderLeftWidth = command;
        }
      });
    },
    handleRightBorder() {
      const first = this.manager.states.visibleCells[0];
      let flag = false;
      if (first.BorderRightLineStyle === 'None') {
        flag = true;
      }
      this.manager.states.visibleCells.forEach(a => {
        a.BorderRightLineStyle = flag ? 'Solid' : 'None';
      });
    },
    handleRightBorderCommand(command) {
      this.manager.states.visibleCells.forEach(a => {
        if (isNaN(command)) {
          a.BorderRightLineStyle = command;
        } else {
          a.BorderRightWidth = command;
        }
      });
    },
    handleTopBorder() {
      const first = this.manager.states.visibleCells[0];
      let flag = false;
      if (first.BorderTopLineStyle === 'None') {
        flag = true;
      }
      this.manager.states.visibleCells.forEach(a => {
        a.BorderTopLineStyle = flag ? 'Solid' : 'None';
      });
    },
    handleTopBorderCommand(command) {
      this.manager.states.visibleCells.forEach(a => {
        if (isNaN(command)) {
          a.BorderTopLineStyle = command;
        } else {
          a.BorderTopWidth = command;
        }
      });
    },
    handleBottomBorder() {
      const first = this.manager.states.visibleCells[0];
      let flag = false;
      if (first.BorderBottomLineStyle === 'None') {
        flag = true;
      }
      this.manager.states.visibleCells.forEach(a => {
        a.BorderBottomLineStyle = flag ? 'Solid' : 'None';
      });
    },
    handleBottomBorderCommand(command) {
      this.manager.states.visibleCells.forEach(a => {
        if (isNaN(command)) {
          a.BorderBottomLineStyle = command;
        } else {
          a.BorderBottomWidth = command;
        }
      });
    },
    handleAlignLeft() {
      this.manager.states.visibleCells.forEach(a => {
        a.TextAlign = 'Left';
      });
    },
    handleAlignCenter() {
      this.manager.states.visibleCells.forEach(a => {
        a.TextAlign = 'Center';
      });
    },
    handleAlignRight() {
      this.manager.states.visibleCells.forEach(a => {
        a.TextAlign = 'Right';
      });
    },
    handleAlignTop() {
      this.manager.states.visibleCells.forEach(a => {
        a.VerticalAlign = 'Top';
      });
    },
    handleAlignMiddle() {
      this.manager.states.visibleCells.forEach(a => {
        a.VerticalAlign = 'Middle';
      });
    },
    handleAlignBottom() {
      this.manager.states.visibleCells.forEach(a => {
        a.VerticalAlign = 'Bottom';
      });
    },
    handleFontBold() {
      const first = this.manager.states.visibleCells[0];
      let flag = false;
      if (first.FontBold) {
        flag = true;
      }
      this.manager.states.visibleCells.forEach(a => {
        a.FontBold = !flag;
      });
    },
    handleFontItalic() {
      const first = this.manager.states.visibleCells[0];
      let flag = false;
      if (first.FontItalic) {
        flag = true;
      }
      this.manager.states.visibleCells.forEach(a => {
        a.FontItalic = !flag;
      });
    },
    handleFontStrikeout() {
      const first = this.manager.states.visibleCells[0];
      let flag = false;
      if (first.FontStrikeout) {
        flag = true;
      }
      this.manager.states.visibleCells.forEach(a => {
        a.FontStrikeout = !flag;
      });
    },
    handleFontUnderline() {
      const first = this.manager.states.visibleCells[0];
      let flag = false;
      if (first.FontUnderline) {
        flag = true;
      }
      this.manager.states.visibleCells.forEach(a => {
        a.FontUnderline = !flag;
      });
    },
    handleWritingMode() {
      const first = this.manager.states.visibleCells[0];
      let flag = 'Horizontal';
      if (first.WritingMode === 'Horizontal') {
        flag = 'Vertical';
      }
      this.manager.states.visibleCells.forEach(a => {
        a.WritingMode = flag;
      });
    },
    handleForeColor(val) {
      this.manager.states.visibleCells.forEach(a => {
        a.ForeColor = val;
      });
    },
    handleBackColor(val) {
      this.manager.states.visibleCells.forEach(a => {
        a.BackColor = val;
      });
    },
    handleFontName(val) {
      this.manager.states.visibleCells.forEach(a => {
        a.FontName = val;
      });
    },
    handleFontSize(val) {
      this.manager.states.visibleCells.forEach(a => {
        a.FontSize = val;
      });
    },
    handleCellType(val) {
      this.manager.states.visibleCells.forEach(a => {
        a.CellType = val;
        a.Text = '';
      });
    },
    handleSelectImage() {
      this.manager.states.EditExpressionVisible = true;
    },
    handleChangeImageName(val) {
      this.manager.states.visibleCells[0].ImageName = val;
    },

  },
};
